package com.google.code.garbagecan.jbossasstudy.stateful;

import java.io.IOException;
import java.io.PrintWriter;

import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet("/stateful/CounterServlet")
public class CounterServlet extends HttpServlet {
	
	@Inject
	Counter counter;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		PrintWriter writer = resp.getWriter();
		
		writer.println("counter.count(): " + counter.count());
		writer.println("counter.reset(): " + counter.reset());
		writer.println("counter.increment(): " + counter.increment());
		writer.println("counter.increment(): " + counter.increment());
		writer.println("counter.reset(): " + counter.reset());

		writer.close();
	}
}
